# test.py 里写一个简单的调用示例
import os
from pyverilog.vparser.parser import parse


def generate_ast(file_path):
    with open(file_path, 'r') as f:
        code = f.read()
    ast, _ = parse(code)
    return ast

def main():
    # 指定路径
    directory_path = 'verilogcode'

    # 遍历路径内的所有文件
    for root, dirs, files in os.walk(directory_path):
        for file in files:
            if file.endswith('.v'):  # 只处理.verilog文件
                file_path = os.path.join(root, file)
                ast = generate_ast(file_path)
                ast.show()

if __name__ == '__main__':
    main()
